package com.woniuxy02;

import java.util.Arrays;

public class Test05 {
    public static void main(String[] args) {
        int[] a = {67,54,32,2,1};
        System.out.println("排序前");
        System.out.println(Arrays.toString(a));

        int temp;
        for (int i = 0; i < a.length-1; i++) {
            System.out.println("第"+i+"轮");
            for (int j = 0; j < a.length-1-i; j++) {
                System.out.println(j+"和"+(j+1)+"两两比较");
                if (a[j] > a[j+1]) {
                    temp = a[j];
                    a[j] = a[j+1];
                    a[j+1] = temp;
                }
            }
        }

        System.out.println("排序后");
        System.out.println(Arrays.toString(a));
    }
}
